<?php
namespace App\Helpers;
use App\Model\OACompany;
use App\Model\OAPositionMapping;
use App\Model\OAWorkNode;
use Psy\Util\Str;

class ProjectHelper
{
    public static function getRolesAndUidsByWorkIdAndGsId(int $workId,int $gsid)
    {
        $workRoles = OAWorkNode::query()->where('work_id',$workId)->pluck('roleid')->toArray();
        $role_list = OAPositionMapping::getPositionMapping($workRoles);
        $role_list = array_map(function ($val){
            return strval($val);
        },$role_list);
        $companyUids = OACompany::getUidsByCompany($gsid);
        $approver = [strval(admin_id())];
        foreach ($companyUids as $role => $uid){
            if(in_array($role,$role_list)) $approver[] = strval($uid);
        }
        return compact('role_list','approver');
    }

}
